package com.gjy.concurrency;

import com.google.common.collect.Lists;
import org.junit.jupiter.api.Test;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-11-14 17:25:00
 */
public class Cft {

    @Test
    public void test3() {
        SimpleDateFormat d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long l = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
        System.out.println("l = " + System.currentTimeMillis() / 1000);
        System.out.println("l = " + l);

        for (int i = 0; i < 10; i++) {
            System.out.println("new Date(l*1000) = " + d.format(new Date(l * 1000)));
            System.out.println("new Date(l*1000) = " + d.format(new Date(System.currentTimeMillis())));
        }
    }

    @Test
    public void test2() {
        ArrayList<Integer> integers = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    }

    @Test
    public void test1() {
        ArrayList<Integer> integers = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        Map<String, List<Integer>> collect = integers.stream()
                .collect(Collectors.groupingBy(integer -> {
                    if (integer % 2 == 0) {
                        return "偶数";
                    } else {
                        return "奇数";
                    }
                }));
        System.out.println("collect = " + collect);
    }
}
